package com.cmcc.xdr.util.sql;

import org.cmcc.pcap.jpcap.util.DateUtil;

import com.cmcc.xdr.entity.HttpEntity;

public class HttpTransactionSaveSqlUtil {
	public static String sql(HttpEntity http,String taskId) {
		String sql = "(" + http.getLength() + ",'" + http.getLocalProvince() + "','" + http.getLocalCity()
		 	+ "','" + http.getOwnerProvince() + "','" + http.getOwnerCity() + "','" + http.getRoamingType()
		 	+ "'," + http.getInterFace() + ",'" + http.getXdrId() + "','" + http.getAppType() + "','"
		 	+ DateUtil.format(http.getProcedureStartTime()) + "','" + DateUtil.format(http.getProcedureEndTime()) + "','" + http.getLongitude() + "','"
		 	+ http.getLatitude() + "'," + http.getHeight() + "," + http.getCoordinateSystem() + ",'" 
		 	+ http.getProtocolType() + "','" + http.getAppType() + "','" + http.getAppSubType() + "'," + http.getAppContent() + "," 
		 	+ http.getAppStatus() + "," + http.getIpAddressType() + ",'" + http.getUserIpv4() + "','" + http.getUserIpv6()+ "'," 
		 	+ http.getUserPort() + "," + http.getL4Protocal() + ",'" + http.getAppServerIpIpv4() + "','" + http.getAppServerIpIpv6() + "'," 
		 	+ http.getAppServerPort() + "," + http.getUlData() + "," + http.getDlData() + "," + http.getUlIpPacket() + "," 
		 	+ http.getDlIpPacket() + "," + http.getUpdura() + "," + http.getDowndura() + "," + http.getUlDisorderIpPacket()+ "," 
		 	+ http.getDlDisorderIpPacket() + "," + http.getUlRetransIpPacket() + "," + http.getDlRetransIpPacket() + "," 
		 	+ http.getTcpResponseTime() + "," + http.getTcpAckTime() + "," + http.getUlIpFragPackets() + "," + http.getDlIpFragPackets() + ","
		 	+ http.getFirstReqTime() + "," + http.getFirstResponseTime() + "," + http.getWindow() + "," + http.getMss() + ","
		 	+ http.getTcpSynNum()+ "," + http.getTcpStatus() + "," + http.getSessionEnd() + "," + http.getTcpSynAckNum() + ","
		 	+ http.getTcpAckNum() + "," + http.getTcp12HandshakeStatus() + "," + http.getTcp23HandshakeStatus() + ",'" 
		 	+ http.getUlProbeid() + "','" + http.getUlLinkIndex() + "','"+ http.getDlProbeid() + "','" + http.getDlLinkIndex() + "','"
		 	+ http.getTransactionid() + "'," + http.getFlowControl() + ","  + http.getUlAvgRtt() + "," + http.getDwAvgRtt() + ",'" + http.getUserAccount() + "',"
		 	+ http.getReferXdrId() + ",'" + http.getHttpVersion() + "','" + http.getMessageType() + "','"  + http.getMessageStatus() + "'," + http.getFirstHttpResponseTime() + ","
		 	+ http.getLastContentPacketTime() + "," + http.getLastAckTime() + "," + http.getHostLength() + ",'"  + http.getHost() + "'," + http.getUriLength() + ",'" 
		 	+ http.getUri() + "'," + http.getxOnlineHostLength() + ",'" + http.getxOnlineHost() + "',"  + http.getUserAgentLength() + ",'" + http.getUserAgent() + "','"
		 	+ http.getHttpContentType() + "'," + http.getReferUriLength() + ",'" + http.getReferUri() + "'," + http.getCookieLength() + ",'" + http.getCookie() + "'," 
		 	+ http.getContentLength() + ",'" + http.getKeyWord() + "'," + http.getServiceBehaviorFlag() + "," + http.getServiceCompFlag() + "," + http.getServiceTime() + "," 
		 	+ http.getIe() + "," + http.getPortal() + "," + http.getLocationLength() + ",'" + http.getLocation() + "'," + http.getFirstRequest() + ",'" + http.getUserAccountLogin() + "'," 
		 	+ http.getUriType() + "," + http.getUriSubType() + "," +taskId+")";
		sql = sql.replaceAll("\'null\'", "null");
		return sql;
	}
}
